import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      component: () => import('../components/Login.vue')
    },
    {
      path: '/dashboard',
      component: () => import('../components/Dashboard.vue')
    }
  ]
})

// 添加导航守卫
router.beforeEach((to, from, next) => {
  if (to.path === '/dashboard' && !to.query.gameId) {
    next('/login')
  } else {
    next()
  }
})

export default router 